#include "tgaimage.h"
#include "geometry.h"
#include "model.h"
#include "mathengine.h"

using mathengine::Vec2i;
using mathengine::Vec3i;
using mathengine::Vec4i;
using mathengine::Vec2f;
using mathengine::Vec3f;
using mathengine::Vec4f;
using mathengine::Matrix44f;
using mathengine::Mat;
using raster::TGAColor;
using raster::TGAImage;


extern Matrix44f ModelView;
extern Matrix44f Viewport;
extern Matrix44f Projection;
extern const float depth;

void viewport(int x, int y, int w, int h);
void projection(float coeff = 0.f); // coeff = -1.f/c
void lookat(Vec3f eye, Vec3f center, Vec3f up);

struct IShader {
    virtual ~IShader() {};
    virtual Vec4f vertex(int iface, int nthvert) = 0; // VS
    virtual bool  fragment(Vec3f bar, TGAColor& color) = 0; // FS
};

void triangle(Vec4f *pts, IShader &shader, TGAImage &image, TGAImage &zbuffer);
void triangle(Mat<float, 4, 3> &clipc, IShader &shader, TGAImage &image, std::vector<float> &zbuffer);
void triangle(Vec4f *pts, IShader &shader, TGAImage &image, std::vector<float> &zbuffer);
